﻿namespace ManagerClinic
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using DevExpress.Skins;
    using DevExpress.LookAndFeel;
    using DevExpress.UserSkins;
    using DevExpress.XtraBars.Helpers;
    using DevExpress.XtraBars;
    using DevExpress.XtraBars.Ribbon;
    using ManagerClinic.Ultilities.Ultility;
    using ManagerClinic.DanhMuc;
    using ManagerClinic.Modules;
    using ManagerClinic.TiepNhan;
    using ManagerClinic.KhamBenh;
    using ManagerClinic.CanLamSang;
    using ManagerClinic.CauHinh;
    using System.Collections;
    using ManagerClinic.HoSoKhamBenh;

    public partial class frmMain : RibbonForm
    {
        public frmMain()
        {
            InitializeComponent();
            InitSkinGallery();

            Authenticate.View = true;
            Authenticate.Add = true;
            Authenticate.Update = true;
            Authenticate.Delete = true;
            Authenticate.Print = true;
            Authenticate.UserName = "dangpp";
            Authenticate.ChuoiPhongKhamVaCanLamSang();

        }

        void InitSkinGallery()
        {
            SkinHelper.InitSkinGallery(rgbiSkins, true);
        }

        static bool IsFormAlreadyOpen(string nameForm)
        {
            foreach (Form OpenForm in Application.OpenForms)
            {
                if (OpenForm.Name == nameForm)
                {
                    OpenForm.Activate();
                    return true;
                }
            }

            return false;
        }

        private void iExit_ItemClick(object sender, ItemClickEventArgs e)
        {
            this.Close();
        }

        private void iDoiMatKhau_ItemClick(object sender, ItemClickEventArgs e)
        {

        }

        private void frmMain_Load(object sender, EventArgs e)
        {

        }

        private void iDmQuocGia_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (Authenticate.IsAuthenticate(Authenticate.sView) == false) return;

            if (IsFormAlreadyOpen("frmDmQuocGia") == true) return;

            frmDmQuocGia frm = new frmDmQuocGia();
            frm.MdiParent = this;
            frm.Show();
        }

        private void iDmTinhThanh_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (Authenticate.IsAuthenticate(Authenticate.sView) == false) return;

            if (IsFormAlreadyOpen("frmDmTinhThanh") == true) return;

            frmDmTinhThanh frm = new frmDmTinhThanh();
            frm.MdiParent = this;
            frm.Show();
        }

        private void iDmQuanHuyen_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (Authenticate.IsAuthenticate(Authenticate.sView) == false) return;

            if (IsFormAlreadyOpen("frmDmQuanHuyen") == true) return;

            frmDmQuanHuyen frm = new frmDmQuanHuyen();
            frm.MdiParent = this;
            frm.Show();
        }

        private void iDmDichVu_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (Authenticate.IsAuthenticate(Authenticate.sView) == false) return;

            if (IsFormAlreadyOpen("frmDmDichVu") == true) return;

            frmDmDichVu frm = new frmDmDichVu();
            frm.MdiParent = this;
            frm.Show();
        }

        private void iDmDichVuChiTiet_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (Authenticate.IsAuthenticate(Authenticate.sView) == false) return;

            if (IsFormAlreadyOpen("frmDmDichVuChiTiet") == true) return;

            frmDmDichVuChiTiet frm = new frmDmDichVuChiTiet();
            frm.MdiParent = this;
            frm.Show();
        }

        private void iKhamChuaBenh_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (Authenticate.IsAuthenticate(Authenticate.sView) == false) return;

            if (IsFormAlreadyOpen("frmDanhSachBenhNhanKhamBenh") == true) return;

            frmDanhSachBenhNhanKhamBenh frm = new frmDanhSachBenhNhanKhamBenh();
            frm.MdiParent = this;
            frm.Show();
        }

        private void iDmLoaiVatTu_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (Authenticate.IsAuthenticate(Authenticate.sView) == false) return;

            if (IsFormAlreadyOpen("frmDMLoaivattu") == true) return;

            frmDmLoaiVatTu frm = new frmDmLoaiVatTu();
            frm.MdiParent = this;
            frm.Show();
        }

        private void iDmNhomVatTu_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (Authenticate.IsAuthenticate(Authenticate.sView) == false) return;

            if (IsFormAlreadyOpen("frmDMNhomvattu") == true) return;

            frmDmNhomVatTu frm = new frmDmNhomVatTu();
            frm.MdiParent = this;
            frm.Show();
        }

        private void iBenhNhan_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (Authenticate.IsAuthenticate(Authenticate.sView) == false) return;

            if (IsFormAlreadyOpen("frmDanhSachBenhNhan") == true) return;

            frmDanhSachBenhNhan frm = new frmDanhSachBenhNhan(this);
            frm.MdiParent = this;
            frm.Show();
        }

        private void iDmPhanLoaiVatTu_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (Authenticate.IsAuthenticate(Authenticate.sView) == false) return;

            if (IsFormAlreadyOpen("frmDMPhanloaiVT") == true) return;

            frmDmPhanLoaiVt frm = new frmDmPhanLoaiVt();
            frm.MdiParent = this;
            frm.Show();
        }

        private void iDmDonVi_ItemClick(object sender, ItemClickEventArgs e)
        {

            if (Authenticate.IsAuthenticate(Authenticate.sView) == false) return;

            if (IsFormAlreadyOpen("frmDMDonvitinh") == true) return;

            frmDmDonViTinh frm = new frmDmDonViTinh();
            frm.MdiParent = this;
            frm.Show();
        }

        private void iXQuang_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (Authenticate.IsAuthenticate(Authenticate.sView) == false) return;

            if (IsFormAlreadyOpen("frmDanhSachPhieuChanDoanHinhAnh") == true) return;

            frmDanhSachPhieuChanDoanHinhAnh frm = new frmDanhSachPhieuChanDoanHinhAnh();
            frm.MdiParent = this;
            frm.Show();
        }

        private void iSieuAm_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (Authenticate.IsAuthenticate(Authenticate.sView) == false) return;

            if (IsFormAlreadyOpen("frmDanhSachPhieuSieuAm") == true) return;

            frmDanhSachPhieuSieuAm frm = new frmDanhSachPhieuSieuAm();
            frm.MdiParent = this;
            frm.Show();
        }

        private void iThamDoChucNang_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (Authenticate.IsAuthenticate(Authenticate.sView) == false) return;

            if (IsFormAlreadyOpen("frmDanhSachPhieuThamDoChucNang") == true) return;

            frmDanhSachPhieuThamDoChucNang frm = new frmDanhSachPhieuThamDoChucNang();
            frm.MdiParent = this;
            frm.Show();
        }

        private void iXetNghiem_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (Authenticate.IsAuthenticate(Authenticate.sView) == false) return;

            if (IsFormAlreadyOpen("frmDanhSachPhieuXetNghiem") == true) return;

            frmDanhSachPhieuXetNghiem frm = new frmDanhSachPhieuXetNghiem();
            frm.MdiParent = this;
            frm.Show();
        }

        private void iPhauThuatThuThuat_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (Authenticate.IsAuthenticate(Authenticate.sView) == false) return;

            if (IsFormAlreadyOpen("frmDanhSachPhieuPhauThuatThuThuat") == true) return;

            frmDanhSachPhieuPhauThuatThuThuat frm = new frmDanhSachPhieuPhauThuatThuThuat();
            frm.MdiParent = this;
            frm.Show();
        }

        private void iDmVatTu_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (Authenticate.IsAuthenticate(Authenticate.sView) == false) return;

            if (IsFormAlreadyOpen("frmDMVattu") == true) return;

            frmDmVatTu frm = new frmDmVatTu();
            frm.MdiParent = this;
            frm.Show();
        }

        private void iGioiTinh_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (Authenticate.IsAuthenticate(Authenticate.sView) == false) return;

            if (IsFormAlreadyOpen("frmDMGioitinh") == true) return;

            frmDmGioiTinh frm = new frmDmGioiTinh();
            frm.MdiParent = this;
            frm.Show();
        }

        private void iTonGiao_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (Authenticate.IsAuthenticate(Authenticate.sView) == false) return;
            if (IsFormAlreadyOpen("frmDMTongiao") == true) return;
            frmDmTonGiao frm = new frmDmTonGiao();
            frm.MdiParent = this;
            frm.Show();
        }

        private void iDanToc_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (Authenticate.IsAuthenticate(Authenticate.sView) == false) return;

            if (IsFormAlreadyOpen("frmDMDantoc") == true) return;

            frmDmDantoc frm = new frmDmDantoc();
            frm.MdiParent = this;
            frm.Show();
        }

        private void iNgheNghiep_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (Authenticate.IsAuthenticate(Authenticate.sView) == false) return;

            if (IsFormAlreadyOpen("frmDMNgheNghiep") == true) return;

            frmDmNgheNghiep frm = new frmDmNgheNghiep();
            frm.MdiParent = this;
            frm.Show();
        }

        private void iBenhVien_ItemClick(object sender, ItemClickEventArgs e)
        {
           
        }

        private void iKhoa_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (Authenticate.IsAuthenticate(Authenticate.sView) == false) return;

            if (IsFormAlreadyOpen("frmDMKhoa") == true) return;

            frmDmKhoa frm = new frmDmKhoa();
            frm.MdiParent = this;
            frm.Show();

        }

        private void iPhong_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (Authenticate.IsAuthenticate(Authenticate.sView) == false) return;

            if (IsFormAlreadyOpen("frmDMPhongkham") == true) return;

            frmDmPhongKham frm = new frmDmPhongKham();
            frm.MdiParent = this;
            frm.Show();
        }

        private void IdmHangsx_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (IsFormAlreadyOpen("frmDMHangsanxuat") == true) return;

            var frm = new frmDmHangSanXuat();
            frm.MdiParent = this;
            frm.Show();
        }

        private void IdmCachdung_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (IsFormAlreadyOpen("frmDmcachdung") == true) return;

            var frm = new frmDmCachDung();
            frm.MdiParent = this;
            frm.Show();
        }

        private void iCauHinh_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (IsFormAlreadyOpen("frmDanhSachCauHinh") == true) return;

            var frm = new frmDanhSachCauHinh();
            frm.MdiParent = this;
            frm.Show();
        }

        private void iDMGhichucachdung_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (IsFormAlreadyOpen("frmDMGhiChuCachDung") == true) return;

            var frm = new frmDmGhiChuCachDung();
            frm.MdiParent = this;
            frm.Show();
        }

        private void IDMnhacungcap_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (IsFormAlreadyOpen("frmDMNhacungcap") == true) return;

            var frm = new frmDmNhaCungCap();
            frm.MdiParent = this;
            frm.Show();
        }

        private void iDMKho_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (IsFormAlreadyOpen("frmDMKho") == true) return;

            var frm = new frmDmKho();
            frm.MdiParent = this;
            frm.Show();
        }

        private void btnDanhSachHoSoKhamBenh_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (IsFormAlreadyOpen("frmDanhSachHoSoKhamBenh") == true) return;

            var frm = new frmDanhSachHoSoKhamBenh(this);
            frm.MdiParent = this;
            frm.Show();
        }
    }
}